package com.example.hasee.zhcd.Adapters;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.example.hasee.zhcd.R;
import com.example.hasee.zhcd.Util.GlobalParameter;

import java.util.ArrayList;
import java.util.HashMap;


/**
 * Created by hasee on 2017/9/13.
 */

public class ChangePortAdapter extends BaseAdapter {
    private HashMap<String, String> map = (HashMap<String, String>) GlobalParameter.get("loginmap");
    private ArrayList<HashMap<String, String>> list;
    private LayoutInflater itemInflater;
    private Context context;
    private Holder holder;

    public ChangePortAdapter(Context context, ArrayList<HashMap<String, String>> list) {
        this.context = context;
        this.list = list;
        this.itemInflater = LayoutInflater.from(context);
    }

    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public Object getItem(int position) {
        return null;
    }

    @Override
    public long getItemId(int position) {
        return 0;
    }

    @Override
    public View getView(final int position, View convertView, ViewGroup parent) {
        if (convertView == null) {
            holder = new Holder();
            convertView = itemInflater.inflate(R.layout.change_port_list_item, null);
            holder.fshipname = (TextView) convertView.findViewById(R.id.fshipname);
            holder.fhc = (TextView) convertView.findViewById(R.id.fhc);
            holder.fyddate = (TextView) convertView.findViewById(R.id.fyddate);
            holder.freason = (TextView) convertView.findViewById(R.id.freason);
            convertView.setTag(holder);
        } else {
            holder = (Holder) convertView.getTag();
        }
        holder.fshipname.setText((String) list.get(position).get("fshipname"));
        holder.fhc.setText((String) list.get(position).get("fhc"));
        holder.fyddate.setText((String) list.get(position).get("fyddate"));
        holder.freason.setText((String) list.get(position).get("freason"));
        return convertView;
    }

    class Holder {
        private TextView fshipname;
        private TextView fhc;
        private TextView fyddate;
        private TextView freason;
    }
}
